<?php
	$title='Manage Site';
	$description='manage';
	$keywords='manage';
?>
<?php include('fns_db_manage_polls.php'); ?>
<?php include('../views/layouts/_header.php'); ?>
<?php include('../views/layouts/_left.php'); ?>
<?php
if(!checkIfAdmin()){
	header("location: ../index.php");
}
?>

<?php
if(isset($_GET['action'])){
	//add poll
	create_new_poll_question($_POST['question']);
	$answers = array($_POST['answer1'], $_POST['answer2'], $_POST['answer3'], $_POST['answer4'], $_POST['answer5']
	, $_POST['answer6'], $_POST['answer7'], $_POST['answer8'], $_POST['answer9'], $_POST['answer10']);
	insert_answers_for_question($_POST['question'], $answers);
	echo 'Poll added successfully!';
}else{

	echo'' .
'Add new poll (by adding a new poll the current one is archived and the new one automatically replaces the current):<br/>' .
'Fill as many answers as you like (up to 10), the bland fields will be just dismissed<br/>


<form name="form1" method="post" action="manage_polls.php?action=add">

	<table width="100%" border="1">
	  <tr>
	    <td>Poll Question:</td>
	    <td><input type="text" name="question" id="question" size="100"></td>
	  </tr>
	  <tr>
	    <td>Answers:</td>
	    <td>
	    	<input type="text" name="answer1" id="answer1" size="50"><br/><br/>
	    	<input type="text" name="answer2" id="answer2" size="50"><br/><br/>
	    	<input type="text" name="answer3" id="answer3" size="50"><br/><br/>
	    	<input type="text" name="answer4" id="answer4" size="50"><br/><br/>
	    	<input type="text" name="answer5" id="answer5" size="50"><br/><br/>
	    	<input type="text" name="answer6" id="answer6" size="50"><br/><br/>
	    	<input type="text" name="answer7" id="answer7" size="50"><br/><br/>
	    	<input type="text" name="answer8" id="answer8" size="50"><br/><br/>
	    	<input type="text" name="answer9" id="answer9" size="50"><br/><br/>
	    	<input type="text" name="answer10" id="answer10" size="50"><br/><br/>
    	</td>
	  </tr>
	</table>

	 <p>
	   <label>
	   <input name="submit" type="submit" id="submit" value="Save">
	   </label>
	</p>
</form>';
}
?>




<?php include('../views/layouts/_footer.php'); ?>